<template>
  <div class="search">
    <f-form ref="form" :action="api.cardserver" :form-key="this.formItem.cardserverId" >
      <f-form-item label="1卡权益初始化，2直接为会员卡添加权益"  name="cardserverType" dataType="number"   :value="formItem.cardserverType" />
      <f-form-item label="电子卡Id"  name="accountGoodsId" dataType="${formField.dataType}"   :value="formItem.accountGoodsId" />
      <f-form-item label="权益id"  name="serverId" dataType="${formField.dataType}"   :value="formItem.serverId" />
      <f-form-item label="服务名称"  name="serverName" dataType="${formField.dataType}"   :value="formItem.serverName" />
      <f-form-item label="计费方式（1期间 2计次）"  name="billingWay" dataType="number"   :value="formItem.billingWay" />
      <f-form-item label="服务类型"  name="serverType" dataType="number"   :value="formItem.serverType" />
      <f-form-item label="服务描述"  name="serverDesc" dataType="${formField.dataType}"   :value="formItem.serverDesc" />
      <f-form-item label="服务编码"  name="serverCode" dataType="${formField.dataType}"   :value="formItem.serverCode" />
      <f-form-item label="数值类型"  name="numType" dataType="number"   :value="formItem.numType" />
      <f-form-item label="初始值"  name="serverValue" dataType="${formField.dataType}"   :value="formItem.serverValue" />
      <f-form-item label=""  name="useValue" dataType="${formField.dataType}"   :value="formItem.useValue" />
      <f-form-item label="剩余值"  name="restValue" dataType="${formField.dataType}"   :value="formItem.restValue" />
      <f-form-item label="权益生效日期"  name="initDate" dataType="${formField.dataType}"   :value="formItem.initDate" />
      <f-form-item label="权益状态"  name="cardserverState" dataType="number"   :value="formItem.cardserverState" />
      <f-form-item label="权益过期日期"  name="expireDate" dataType="${formField.dataType}"   :value="formItem.expireDate" />
      <f-form-item label="创建日期"  name="createDate" dataType="${formField.dataType}"   :value="formItem.createDate" />
    </f-form>
  </div>
</template>
<script>
  import api from './js/api'
  export default {
    name: 'cardserverForm',
    props: {},
    data() {
      return {
        refs:this.$refs,
        api:  Object.assign(api, this.api),
        isAdd: true,//是否是添加模式
        loaded: false,//是否加载完成
        formItem: this.getFormItem()
      }
    },
    methods: {
      getFormItem() {
        return {
          cardserverId: '',
          cardserverType: '',
          accountGoodsId: '',
          serverId: '',
          serverName: '',
          billingWay: '',
          serverType: '',
          serverDesc: '',
          serverCode: '',
          numType: '',
          serverValue: '',
          useValue: '',
          restValue: '',
          initDate: '',
          cardserverState: '',
          expireDate: '',
          createDate: ''
        }
      },
      //表单赋值
      setData(data) {
        this.$refs.form.resetFields()
        this.formItem = this.getFormItem()
        if (data && data.cardserverId) {
          let params={
              cardserverId:data.cardserverId
          }
          this.refs['form'].getDetails(params,(data)=>{
             this.formItem=data
             this.loaded = true
          })
          this.isAdd = false
        } else {
          this.loaded = true
        }
      },
      //提交表单
      handleSubmit(callback) {
        this.$refs.form.submit({  }, callback)
      }
    },
    created() {
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
